package rdd.transform

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark01_RDD_Filter_Test {
  def main(args: Array[String]): Unit = {
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)
    //从服务器上获取请求路径
    val rdd: RDD[String] = sc.textFile("data/apache.log")
    val filterRDD: RDD[String] = rdd.filter(
      item => {
        val strings: Array[String] = item.split(" ")
        val time: String = strings(3)
        time.startsWith("17/05/2015")
      }
    )
    val mapRDD: RDD[String] = filterRDD.map(
      line => {
        val strings: Array[String] = line.split(" ")
        strings(6)

      })
    mapRDD.collect().foreach(println)
    sc.stop()
  }

}
